package com.cuitrip.business.bill;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cuitrip.component.item.ItemLayout;
import com.cuitrip.component.page.SimpleEmptyFragmentActivity;
import com.cuitrip.service.R;
import com.cuitrip.util.time.InputTime;
import com.cuitrip.util.time.OutputTime;
import com.cuitrip.util.time.TimeUtil;
import com.lab.app.BaseActivity;
import com.lab.app.customui.CustomUiConfig;
import com.lab.app.customui.CustomUiFragment;
import com.lab.utils.NumberUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by MiJack on 2015/11/6.
 */
public class RewardFragment extends CustomUiFragment {
    private static final String KEY_MONEY       = "KEY_MONEY";
    private static final String KEY_MONEY_TYPE  = "KEY_MONEY_TYPE";
    private static final String KEY_TIME        = "KEY_TIME";
    @Bind(R.id.layoutTripType)
    ItemLayout layoutTripType;
    @Bind(R.id.layoutUserNick)
    ItemLayout layoutUserNick;
    @Bind(R.id.layoutTime)
    ItemLayout layoutTime;
    @Bind(R.id.moneyType)
    TextView tvMoneyType;
    @Bind(R.id.moneyCount)
    TextView tvMoneyCount;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view= super.onCreateView(inflater, container, savedInstanceState, R.layout.fragment_reward_detail);
        ButterKnife.bind(this, view);
        String money=getArguments().getString(KEY_MONEY);
        String moneyType=getArguments().getString(KEY_MONEY_TYPE);
        String time=getArguments().getString(KEY_TIME);
        tvMoneyType.setText(moneyType);
        tvMoneyCount.setText(NumberUtils.getMoneyFormat(money));
        layoutTripType.setmRightText(getString(R.string.transaction_attribute_type_reward));
        layoutUserNick.setmRightText(getString(R.string.app_name));
        layoutTime.setmRightText(
                TimeUtil.formatTime(
                        InputTime.build(time),
                        OutputTime.getLocalInstance(OutputTime.OutputType.Type_Minute))
        );
        return  view;
    }

    @Override
    public boolean initCloseTopBar() {
        return false;
    }

    @Override
    public void onTopbarLeftPress() {
        getActivity().finish();
    }

    @Override
    public CustomUiConfig initCustomUiConfig() {
        CustomUiConfig customUiConfig = new CustomUiConfig();
        customUiConfig.mTopbarMiddleAreaName = getString(R.string.transaction_detail);
        customUiConfig.mTopbarLeftAreaName = getString(R.string.back_icon);
        customUiConfig.mTopbarStyle= CustomUiConfig.BarStyle.WHITE_STYLE;
        return customUiConfig;
    }
    public static void startFragment(BaseActivity activity, String money, String moneyType, String time) {
        Bundle  args=new Bundle();
        args.putString(KEY_MONEY,money);
        args.putString(KEY_MONEY_TYPE,moneyType);
        args.putString(KEY_TIME,time);
        SimpleEmptyFragmentActivity.startFragmentActivity(activity, RewardFragment.class, args);
    }
}
